import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wch/widget/common_widget.dart';
import 'package:wch/widget/padding_widget.dart';
import 'package:wch/widget/text_widget.dart';

import '../constant/resource_constant.dart';

class CommonInputWidget {
  static Widget getInputWidget(String label, String content, String hint, [bool isNeedLine = false]) {
    return Container(
      height: 52.h,
      child: Column(
        children: [
          Row(
            children: [
              HorPadding(20.w),
              Container(
                width: 120.w,
                child: F15TitleText(label, color: F1TextColor),
              ),
              Expanded(
                  child: CupertinoTextField(
                    placeholderStyle: TextStyle(
                      color: hintColor,
                      fontSize: 15.w,
                    ),
                    placeholder: hint,
                    style: TextStyle(color: F1TextColor, fontSize: 15.w),
                    decoration: const BoxDecoration(color: Colors.transparent),
                  )),
              HorPadding(20.w),

            ],
          ),
          Offstage(
            offstage: !isNeedLine,
            child: LineWidget(
                color: lineColor, height: 0.5, width: ScreenUtil().screenWidth - 70.w,
            ),
          )
        ],
      ),
    );
  }

  ///普通的展示文本
  static Widget getShowWidget(String label, String content, [Color highlightColor = F1TextColor]) {
    return Container(
      height: 52.h,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          HorPadding(20.w),
          Container(
            width: 120.w,
            child: F15TitleText(label, color: F1TextColor),
          ),
          Expanded(
            child: Container(
              child: Text(
                content,
                textAlign: TextAlign.right,
                style: TextStyle(
                  color: highlightColor,
                  fontSize: 15,
                ),
              )
            )
          ),
          HorPadding(20.w)
        ],
      ),
    );
  }

  static Widget getSelectWidget(String label, String content, String hint) {
    return Container(
      height: 52.h,
      child: Row(
        children: [
          HorPadding(20.w),
          Container(
            width: 127.w,
            child: F15TitleText(label, color: F1TextColor),
          ),
          Expanded(
              child: F15TitleText(
                content.isNotEmpty ? content : hint,
                color: content.isNotEmpty ? F1TextColor : hintColor,
              )),
          HorPadding(10.w),
          Image.asset(
            arrowRightPng,
            width: 11.w,
            height: 11.w,
          ),
          HorPadding(20.w)
        ],
      ),
    );
  }

  static Widget getSetSelectWidget(String label, String content) {
    return Container(
      height: 52.h,
      child: Row(
        children: [
          Container(
            width: 127.w,
            child: F15TitleText(label, color: F1TextColor),
          ),
          Expanded(child: Container(),),
          content.isEmpty ?
          Image.asset(
            arrowRightPng,
            width: 11.w,
            height: 11.w,
          ) : F15TitleText(
            content,
            color: content.isNotEmpty ? F1TextColor : hintColor,
          ),
        ],
      ),
    );
  }
}
